import QtQuick 2.2
import QtQuick.Controls 1.1
import com.hanvon.face 1.0

ApplicationWindow {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    menuBar: MenuBar {
        Menu {
            title: qsTr("File")
            MenuItem {
                text: qsTr("Exit")
                onTriggered: Qt.quit();
            }
        }
        Menu {
            title: qsTr("Camera")
            MenuItem {
                text: qsTr("Open")
                onTriggered: {
                    faceitem.running=true
                }
            }
        }
    }
    FaceAction{
        id: faceaction
        videobuf: cambuf
        actionType: FaceAction.ACTION_IDLE
    }

    CameraVideoBuffer{
        id: cambuf
        running: false
        camid: 0
    }

    FaceVideoItem{
        id: faceitem

        running: true
        videobuf: cambuf
        videoproc: faceaction

        anchors.top: parent.top
        anchors.left: parent.left
        anchors.right: parent.right
        anchors.bottom: textinput.top
        anchors.margins: 5
    }

    LineEdit{
        id: textinput
        anchors.left: parent.left
        anchors.bottom: parent.bottom

        width: 100
        height: 40
        focus: true

        KeyNavigation.tab: button
        text: "Input"
    }
    Button{
        id: button
        anchors.left: textinput.right
        anchors.bottom: textinput.bottom

        width: 50
        height: 40
        text: "OK"

        onClicked: {
            console.log("Button Clicked")
            faceitem.running=true
            cambuf.running=true;
            faceaction.actionType=FaceAction.ACTION_DETECT;
        }

        KeyNavigation.tab: textinput
    }
}
